package com.shop.shoppingmall.controller;

import com.shop.shoppingmall.entity.ShWallet;
import com.shop.shoppingmall.service.ShWalletService;
import com.shop.shoppingmall.util.api.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Map;

/**
 * 钱包账户(ShWallet)表控制层
 *
 * @author makejava
 * @since 2020-09-05 14:23:03
 */
@RestController
@RequestMapping("shWallet")
@CrossOrigin
public class ShWalletController {
    /**
     * 服务对象
     */
    @Resource
    private ShWalletService shWalletService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public ShWallet selectOne(String id) {
        return this.shWalletService.queryById(id);
    }

    /**
     * 设置支付密码
     * @param
     * @param
     * @param request
     * @return
     */
    @PostMapping("/insertWalletOfPassword")
    public Result insertWalletOfPassword(@RequestBody Map map, HttpServletRequest request){
        String password = (String) map.get("password");
        return shWalletService.insertWalletOfPassword(password,request);
    }

    /**
     * 兑换馨天币
     * @param
     * @return
     */
    @PostMapping("/updateWalletOfDayCoin")
    public Result updateWalletOfDayCoin(@RequestBody Map map, HttpServletRequest request){
        Integer integral = (Integer) map.get("integral");
        return shWalletService.updateWalletOfDayCoin(request,integral);
    }

    /**
     * 查询钱包的有关信息
     * @param request
     * @return
     */
    @GetMapping("/selectWalletAll")
    public Result selectWalletAll(HttpServletRequest request){
        return shWalletService.selectWalletAll(request);
    }

    /**
     * 输入支付密码进行支付
     * @param
     * @param request
     * @return
     */
    /*@PostMapping("/paymentWallet")
    public Result paymentWallet(@RequestBody Map map, HttpServletRequest request){
        String password = (String) map.get("password");
        return shWalletService.paymentWallet(password,request);
    }*/

    /**
     * 查询是否设置过支付密码
     * @param request
     * @return
     */
    @GetMapping("/selectShWalletPassWord")
    public Result selectShWalletPassWord(HttpServletRequest request){
        return shWalletService.selectShWalletPassWord(request);
    }

    /**
     * 根据实体条件查询钱包的信息
     * @param map
     * @return
     */
    @PostMapping("/selectQueryWalletAll")
    public Result selectQueryWalletAll(@RequestBody Map map){

        return shWalletService.selectQueryWalletAll(map);
    }

    @PostMapping("/selectAll")
    public Result selectAll(HttpServletRequest request){

        return shWalletService.selectAll(request);
    }

}
